package com.xmz.cacheaside.request;

import com.xmz.cacheaside.model.ProductInventory;
import com.xmz.cacheaside.service.ProductInventoryService;

public class ProductQueryRequest implements Request{

    private ProductInventoryService productInventoryService;
    /**
     * 商品id
     */
    private Integer productId;


    public ProductQueryRequest(ProductInventoryService productInventoryService,
                               Integer productId) {
        this.productInventoryService = productInventoryService;
        this.productId = productId;
    }

    @Override
    public void process() {
        //查询db
        ProductInventory productInventory = productInventoryService.findProductInventory(productId);

        //设置缓存
        productInventoryService.setProductInventoryCache(productInventory);
    }

    @Override
    public Integer getProductId() {
        return productId;
    }
}
